<template>
  <div>
    <el-dialog title="题目浏览" :visible.sync="dialogFormVisible">
      <div class="box">
        <el-row>
          <el-col v-if="formList.questionType == 1" :span="5">[题型] : 单选</el-col>
          <el-col v-else-if="formList.questionType == 2" :span="5">[题型] : 多选</el-col>
          <el-col v-else :span="5">[题型] : 简答</el-col>
          <el-col :span="5">[编号] : {{formList.id}}</el-col>
          <el-col :span="5">[难度] : {{formList.difficulty == 1?'简单':'困难'}}</el-col>
          <el-col :span="9">[标签] : {{formList.tags}}</el-col>
        </el-row>

        <el-row class="top">
          <el-col :span="5">[学科] : {{formList.subjectName}}</el-col>
          <el-col :span="5">[目录] : {{formList.catalogID}}</el-col>
          <el-col :span="5">[方向] : {{formList.direction}}</el-col>
        </el-row>
        <el-row class="top">
          [题干] :
          <div style="color:blue;margin-top:10px" v-html="formList.question"></div>
          <div style="margin-top: 5px">
            <template v-if="formList.questionType ==1">
              <br />单选题 选项: (以下选中的选项为正确答案)
              <div v-for="item in formList.options" :key="item.id">
                <el-radio-group :value="1">
                  <el-radio
                    style="margin-top:10px"
                    v-model="radio"
                    :label="item.isRight"
                  >{{item.title}}</el-radio>
                </el-radio-group>
              </div>
            </template>
            <template v-else-if="formList.questionType == 2">
              <br />多选题 选项: (以下选中的选项为正确答案)
              <div v-for="item in formList.options" :key="item.id">
                <el-checkbox-group :value="[1]">
                  <el-checkbox
                    style="margin-top:10px"
                    v-model="checkedCities"
                    :label="item.isRight"
                  >{{item.title}}</el-checkbox>
                </el-checkbox-group>
              </div>
            </template>
          </div>
        </el-row>
      </div>

      <el-row class="box">
        [参考答案] :
        <el-button type="danger" @click="videoLoading = true">视频答案预览</el-button>
        <el-dialog title="答案" append-to-body :visible.sync="videoLoading">
          <video
            autoplay="autoplay"
            style="width:100%"
            :src="formList.videoURL"
            v-if="videoLoading"
          ></video>
        </el-dialog>
      </el-row>
      <el-row class="box">
        [答案解析] :
        <span v-html="formList.answer"></span>
      </el-row>
      <el-row class="box1">[题目备注] : {{formList.remarks}}</el-row>
      <el-row>
        <el-button class="guanbi" @click="closeVisible" type="primary">关闭</el-button>
      </el-row>
    </el-dialog>
  </div>
</template>
<script>
export default {
  name: 'questions-preview',
  props: ['formList'],
  data () {
    return {
      dialogFormVisible: false,
      radio: '', // 单选
      checkedCities: [], // 多选
      videoLoading: false
    }
  },
  methods: {
    openVisible () {
      this.dialogFormVisible = true
    },
    closeVisible () {
      this.dialogFormVisible = false
    }
  }
}
</script>
<style>
.top {
  margin-top: 20px;
}
.box {
  padding: 15px;
  border-bottom: solid;
}
.box1 {
  padding: 15px;
}
.danxuan > el-radio {
  margin-top: 5px;
}
.guanbi {
  display: block;
  margin: 0 auto;
  margin-top: 20px;
}
.rad {
  margin-top: 5px;
}
</style>
